import React, { Component } from 'react';
import classNames from 'classnames';
import CheckboxGroup from './Group';
import BaseCheckbox from './BaseCheckbox';
import './style/index.less';

export default class Checkbox extends Component {
  static Group = CheckboxGroup;
  static defaultProps = {
    prefixCls: 'ant-checkbox',
    indeterminate: false
  }

  render() {
    const {
      prefixCls, style, children, className, indeterminate,
      onMouseEnter, onMouseLeave, ...restProps
    } = this.props;
    const classString = classNames(className, {
      [`${prefixCls}-wrapper`]: true
    });
    const checkboxClass = classNames({
      [`${prefixCls}-indeterminate`]: indeterminate
    });
    return (
      <label
        className={classString}
        style={style}
        onMouseEnter={onMouseEnter}
        onMouseLeave={onMouseLeave}
      >
        <BaseCheckbox
          {...restProps}
          prefixCls={prefixCls}
          className={checkboxClass}
          // children={null}
        />
        {children !== undefined ? <span>{children}</span> : null}
      </label>
    );
  }
}
